<template>
	<el-row>
		<el-col class="top">
			<label>诊断抢救成功率</label>
		</el-col>
		<el-col>
			<el-row class="dateBar">
				<el-col>
					<el-date-picker
					v-model="timeRange"
					type="datetimerange"
					range-separator="至"
					start-placeholder="开始日期"
					end-placeholder="结束日期">
					</el-date-picker>
					<el-button type="primary" @click="getStatistic">确定</el-button>
				</el-col>
			</el-row>
		</el-col>
		<el-col>
			<el-row>
				<el-col class="infoTitle">
					<el-row>
						<el-col :span="18">
							<i class="el-icon-menu"></i>以下诊断抢救成功率
							<span class="timeRange">{{timeString}}</span>
						</el-col>
						<el-col :span="6" class="actionBtn">
							<el-button-group>
								<el-button type="primary" size="small" disabled>结果导出</el-button>
								<el-button type="primary" size="small" disabled>结果打印</el-button>
							</el-button-group>
						</el-col>
					</el-row>
				</el-col>
				<el-col>
					<table class="infoTable">
						<thead>
							<tr>
								<th>类别</th>
								<th>呼吸衰竭</th>
								<th>急性左心衰</th>
								<th>感染性休克</th>
								<th>失血性休克</th>
								<th>急性心肌梗死</th>
								<th>主动脉夹层</th>
								<th>肺栓塞</th>
								<th>脑出血</th>
								<th>蛛网膜下腔出血</th>
								<th>脑外伤</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<td>
									成功率<br>(成功/总数)
								</td>
								<td>
									{{commonUtil.toPercent(allData.hxsjS,allData.hxsj)}}
									<br>
									({{allData.hxsjS?allData.hxsjS:"-"}}/{{allData.hxsj?allData.hxsj:"-"}})
								</td>
								<td>
									{{commonUtil.toPercent(allData.jxzxsS,allData.jxzxs)}}
									<br>
									({{allData.jxzxsS?allData.jxzxsS:"-"}}/{{allData.jxzxs?allData.jxzxs:"-"}})
								</td>
								<td>
									{{commonUtil.toPercent(allData.grxxkS,allData.grxxk)}}
									<br>
									({{allData.grxxkS?allData.grxxkS:"-"}}/{{allData.grxxk?allData.grxxk:"-"}})
								</td>
								<td>
									{{commonUtil.toPercent(allData.sxxxkS,allData.sxxxk)}}<br>({{allData.sxxxkS?allData.sxxxkS:"-"}}/{{allData.sxxxk?allData.sxxxk:"-"}})
								</td>
								<td>
									{{commonUtil.toPercent(allData.jxxjgsS,allData.jxxjgs)}}
									<br>
									({{allData.jxxjgsS?allData.jxxjgsS:"-"}}/{{allData.jxxjgs?allData.jxxjgs:"-"}})
								</td>
								<td>
									{{commonUtil.toPercent(allData.zdmjcS,allData.zdmjc)}}
									<br>
									({{allData.zdmjcS?allData.zdmjcS:"-"}}/{{allData.zdmjc?allData.zdmjc:"-"}})
								</td>
								<td>
									{{commonUtil.toPercent(allData.fssS,allData.fss)}}
									<br>
									({{allData.fssS?allData.fssS:"-"}}/{{allData.fss?allData.fss:"-"}})
								</td>
								<td>
									{{commonUtil.toPercent(allData.ncxS,allData.ncx)}}
									<br>
									({{allData.ncxS?allData.ncxS:"-"}}/{{allData.ncx?allData.ncx:"-"}})
								</td>
								<td>
									{{commonUtil.toPercent(allData.zwmxqcxS,allData.zwmxqcx)}}
									<br>
									({{allData.zwmxqcxS?allData.zwmxqcxS:"-"}}/{{allData.zwmxqcx?allData.zwmxqcx:"-"}})
								</td>
								<td>
									{{commonUtil.toPercent(allData.nwsS,allData.nws)}}
									<br>
									({{allData.nwsS?allData.nwsS:"-"}}/{{allData.nws?allData.nws:"-"}})
								</td>
							</tr>
						</tbody>
					</table>
				</el-col>
			</el-row>
		</el-col>
	</el-row>
</template>
<script type="text/javascript">
	export default{
		name:'Diagnosis',
		data(){
			return {
				timeRange:[new Date((new Date()).getTime()-3600*1000*24*1),new Date()],
				timeString:"",
				curUser:{},
				allData:{}
			}
		},
		mounted(){
			if (this.$cookies.get("curUser")) {
				this.curUser = this.$cookies.get("curUser");
			}
		},
		methods:{
			getStatistic:function(){
				var vm = this;
				var startTime = new Date();
				var lastTime = new Date((new Date()).getTime()-3600*1000*24*1);
				if (vm.timeRange.length==2) {
					startTime = vm.timeRange[0];
					lastTime = vm.timeRange[1];
				}
				vm.setTimeString();
				var hospitalCode = vm.curUser.hospitalCode;
				this.$axios.getDiseaseData(vm.commonUtil.dateFormat(startTime,"yyyy-MM-dd hh:mm:ss"),vm.commonUtil.dateFormat(lastTime,"yyyy-MM-dd hh:mm:ss"),hospitalCode).then(function(res){
					if (res.data&&res.data.data) {
						vm.allData = res.data.data;
					}
				},function(res){
					console.log("error:"+res);
				});
			},
			setTimeString:function(){
				let vm = this;
				if (vm.timeRange.length==2) {
					let startTime = vm.timeRange[0];
					let lastTime = vm.timeRange[1];
					vm.timeString = "("+vm.commonUtil.dateFormat(startTime,"yyyy-MM-dd hh:mm:ss")+" 至 "+vm.commonUtil.dateFormat(lastTime,"yyyy-MM-dd hh:mm:ss")+")";
				}else{
					vm.timeString ="";
				}
			}
		}
	}
</script>
<style type="text/css" scoped>
	.top{
		font-weight: bolder;
		line-height: 45px;
		height: 45px;
		border-bottom: 1px dashed #eeeeee;
	}
	.dateBar{
		text-align: center;
		margin-top: 10px;
		margin-bottom: 10px;
	}
	.infoTable{
		 width:100%;
		 table-layout:fixed;
		 border-right: solid 1px #000000;
		 border-bottom: solid 1px #000000;
		 border-collapse: collapse;
		 text-align: center;
		 line-height: 45px;
		 font-size: 14px;
	}
	.infoTable th{
		border-left: solid 1px #000000;
		border-top: solid 1px #000000;
		background-color: lightblue;
	}
	.infoTable td{
		border-left: solid 1px #000000;
		border-top: solid 1px #000000;
	}
	.infoTitle{
		font-weight: bolder;
		color: #000000;
		margin-top: 30px;
		text-align: left;
		line-height: 45px;
	}
	.actionBtn{
		text-align: right;
		padding-right: 10px;
	}
	.tips{
		font-size: 10pt;
		font-weight: lighter;
		color: #888888;
	}
	.timeRange{
		font-weight: lighter;
	}
</style>